home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / test / MazezaM.c < prev    next >
Text File  |  2003-12-31  |  9KB  |  278 lines

  1. /*
  2.     ***********************
  3.     *******         *******
  4.     ******* MazezaM *******
  5.     *******         *******
  6.     ***********************
  7.  
  8.       Copyright (C) 2002
  9.        Malcolm  Tyrrell
  10.       tyrrelmr@cs.tcd.ie
  11.  
  12.      Amiga Version (C) 2003
  13.       Ventzislav  Tzvetkov
  14.      drHirudo@Amigascne.org
  15.  
  16.      GameBoy version (C) 2004
  17.        Ventzislav  Tzvetkov
  18.      drHirudo@Amigascne.org
  19.      http://drhirudo.hit.bg
  20.      Compile with GBDK and
  21.      following command line:
  22.  
  23.    lcc MazezaM.c -o MazezaM.gb
  24.  
  25.  
  26.      This code may be used
  27.      and distributed under
  28.      the terms of the GNU
  29.      General Public Licence.
  30.  
  31. */
  32.  
  33. #include <gb.h>
  34. #include <drawing.h>
  35. #include <string.h>
  36. #include <rand.h>
  37.  
  38. int w,h,i,j,l,t,r,rx,lx,lives;
  39.  
  40. char *a[20][20],b[20][20];
  41.  
  42. void fadein(){
  43.  BGP_REG = 0x40U;delay(59); BGP_REG = 0x90U;delay(59); BGP_REG = 0xE4U;}
  44.  
  45. void fadeout() {
  46.  BGP_REG = OBP0_REG = OBP1_REG = 0x90U;
  47.  delay(59); BGP_REG = OBP0_REG = OBP1_REG = 0x40U;
  48.  delay(59);BGP_REG = OBP0_REG = OBP1_REG = 0x00U;}
  49.  
  50. void Wait(){
  51. wait_vbl_done();wait_vbl_done();wait_vbl_done();wait_vbl_done();
  52. }
  53.  
  54. void Level(int mazenumber){int k;
  55. char *n[20],*c[20];
  56. gotogxy(0,0);
  57. switch (mazenumber)
  58.    {
  59.    case 1: { n[0]="Humble Origins";c[0]="©Malcolm Tyrrell";w=7;h=2;
  60.    lx=1;rx=1;a[1][0]=" €  €  ";a[2][0]=" €  ƒ ";break; }
  61.  
  62.  
  63.    case 2: { n[0]="Easy Does It";c[0]="©Malcolm Tyrrell";w=8;h=3;
  64.    lx=3;rx=2;a[1][0]="  €  ‚ƒ";a[2][0]="  € € € ";
  65.    a[3][0]=" € € €  ";break;}
  66.  
  67.    case 3: { n[0]="Up, Up and Away";c[0]="©Malcolm Tyrrell";w=5;h=11;
  68.    lx=11;rx=1;a[1][0]="  €  ";a[2][0]=" € ƒ";a[3][0]=" ƒ  ";
  69.    a[4][0]="€ €  ";a[5][0]=" € € ";a[6][0]=" ‚ƒ ";a[7][0]="€ €  ";
  70.    a[8][0]=" € € ";a[9][0]=" € € ";a[10][0]="€ ƒ ";a[11][0]=" €   ";break;}
  71.  
  72.    case 4: { n[0]="To and Fro";c[0]="©Malcolm Tyrrell";w=13;h=6;lx=1;rx=1;
  73.    a[1][0]="   ‚‚‚ƒ     ";a[2][0]="€ ‚‚‚ƒ  ‚ƒ ";a[3][0]=" € ‚ƒ ‚‚ƒ  ";
  74.    a[4][0]="€ €  ‚‚‚‚‚ƒ ";a[5][0]=" ‚ƒ €   ƒ  ";a[6][0]="€ € € ƒ  €  ";
  75.    break;}
  76.  
  77.    case 5: { n[0]="Loop-de-Loop";c[0]="©Malcolm Tyrrell";w=14;h=4;lx=2;rx=4;
  78.    a[1][0]=" ‚‚‚ƒ ƒ ƒ  ";a[2][0]="   ƒ  ƒ  ƒ ";
  79.    a[3][0]="ƒ  € ƒ ‚ƒ  ";a[4][0]="   ‚‚‚‚‚‚ƒ  €";break;}
  80.  
  81.    case 6: { n[0]="Be Prepared";c[0]="©Malcolm Tyrrell";w=7;h=6;lx=5;rx=3;
  82.    a[1][0]="   €   ";a[2][0]=" ‚‚ƒ  ";a[3][0]=" ‚ƒ ƒ";
  83.    a[4][0]=" € € € ";a[5][0]=" € ƒ  ";a[6][0]="€ ƒ   ";break;}
  84.  
  85.    case 7: {n[0]="Two Front Doors";c[0]="©Malcolm Tyrrell";
  86.    w=16;h=7;lx=1;rx=7;a[1][0]="       ‚‚‚‚‚ƒ  ";
  87.    a[2][0]="  ‚‚ƒ ‚‚ƒ € € ";a[3][0]="ƒ ƒ ‚‚‚‚ƒ € €";
  88.    a[4][0]="ƒ     € €      ";a[5][0]="  ‚‚‚‚‚‚‚‚‚‚‚ƒ ";
  89.    a[6][0]=" € ƒ    € ‚ƒ  ";a[7][0]="  €   ‚ƒ     ƒ";break;}
  90.  
  91.    case 8: { n[0]="Through, through";
  92.    c[0]="©Malcolm Tyrrell";w=15;h=4;lx=3;rx=1;
  93.    a[1][0]=" ‚‚ƒ  ‚‚ƒ  ƒ";a[2][0]=" € ƒ ƒ € ƒ  ";
  94.    a[3][0]=" € ƒ ‚‚ƒ ƒ  ";a[4][0]=" € ƒ  ‚‚ƒ  € ";break;}
  95.  
  96.    case 9: { n[0]="Double Cross";c[0]="©Malcolm Tyrrell";w=9;h=7;lx=7;rx=3;
  97.    a[1][0]=" €  ‚‚ƒ ";a[2][0]=" €  € ƒ ";a[3][0]=" € ‚‚ƒ €";
  98.    a[4][0]="€ ƒ  €  ";a[5][0]="  €   ‚ƒ";a[6][0]=" ‚‚‚‚ƒ  ";
  99.    a[7][0]="  €      ";break;}
  100.  
  101.    case 10: { n[0]="Inside Out";c[0]="©Malcolm Tyrrell";w=14;h=10;lx=8;rx=1;
  102.    a[1][0]="            € ";a[2][0]=" ‚‚‚‚‚‚‚‚ƒ  €";
  103.    a[3][0]=" ‚ƒ       ƒ ";a[4][0]=" € ‚‚‚‚‚‚ƒ € ";
  104.    a[5][0]=" ‚ƒ ‚ƒ  ‚ƒ ";a[6][0]=" ‚ƒ   €  ‚ƒ ";
  105.    a[7][0]=" € ‚‚‚‚‚ƒ ƒ ";a[8][0]=" € € €    ‚ƒ ";
  106.    a[9][0]=" ‚‚‚‚‚‚‚‚‚‚ƒ ";a[10][0]="              ";break;}
  107.  
  108.  
  109.    default: {fadeout();color(BLACK,WHITE,SOLID);gprint("  „„                „„„„                „„„„");
  110.    color(LTGREY,WHITE,SOLID);gprint("      You have  ");color(BLACK,WHITE,SOLID);gprint("„„„„");
  111.    color(LTGREY,WHITE,SOLID);gprint("      Escaped.  ");color(BLACK,WHITE,SOLID);gprint("„„„„     ");
  112.    color(DKGREY,BLACK,SOLID);gprint("WELL DONE!");color(BLACK,WHITE,SOLID);
  113.    gprint(" „„„„                „„„„                „„„„                „„„„                ____                „„„„");
  114.    color(DKGREY,WHITE,SOLID);gprint("‚ƒ");color(BLACK,LTGREY,SOLID);
  115.    gprint("‡‡‡‡‡‡‡‡‡‡‡‡‡");color(BLACK,WHITE,SOLID);gprint("„„„„   ");
  116.    color(BLACK,LTGREY,SOLID);gprint("‡‡‡‡‡‡‡‡‡‡‡‡‡");
  117.    for (i=0;i<6;i++)
  118.   {color(BLACK,WHITE,SOLID);gprint("„„„„");color(DKGREY,WHITE,SOLID);gprint("†††");
  119.    color(BLACK,LTGREY,SOLID);gprint("‡‡‡‡‡‡‡‡‡‡‡‡‡");}
  120.    fadein();color(BLACK,WHITE,SOLID);
  121.    for (i=0;i<20;i++) {
  122.    if (i<14 || i>16 ) {gotogxy(i,9);gprint("");}
  123.    if (i >= 14 && i <= 16) {gotogxy(i,22-i);gprint("");}
  124.    Wait();
  125.    if (i==15) {gotogxy(12,5);gprint("Hurray!");}
  126.    if (i==18) {gotogxy(12,5);gprint("       ");}
  127.    if (i<4) {gotogxy(i,9);gprint("_");}
  128.    if ((i>3 && i<14) || i>16) {gotogxy(i,9);gprint(" ");}
  129.    if (i >= 14 && i <= 16) {gotogxy(i,22-i);gprint(" ");}
  130.   }
  131.   delay(8200);fadeout();reset();}
  132.  }
  133. for (i=1;i<h+1;i++) strcpy(&b[i][0],a[i][0]);
  134. l=((20-w)/2);t=((20-h)/2);r=20-l-w;color(BLACK,WHITE,SOLID);
  135. gprint("„„");color(DKGREY,WHITE,SOLID);
  136. gprint("Level ");if (mazenumber<10) gprintf("0%d",mazenumber);
  137.                    else gprintf("%d",mazenumber);
  138. color(BLACK,WHITE,SOLID); gprint("„");color(LTGREY,WHITE,SOLID);
  139. gprint("Lives ");gprintf("%d",lives);
  140. color(BLACK,WHITE,SOLID);gprint("„„");
  141.  
  142. for (i=1;i<t+1;i++) gprint("„„„„„„„„„„„„„„„„„„„„");
  143.  
  144. for (i=1;i<h+1;i++){
  145. if (i==lx) for (k=0;k<l;k++) gprint("_");
  146. if (i!=lx) for (k=0;k<l;k++) gprint("„");
  147. color(i%2+1,WHITE,SOLID);gprint(a[i][0]);
  148. color(BLACK,WHITE,SOLID);
  149. if (i==rx) for (k=0;k<r;k++) gprint("_");
  150. if (i!=rx) for (k=0;k<r;k++) gprint("„");
  151. }
  152.  
  153. for (i=t+h+1;i<17;i++) gprint("„„„„„„„„„„„„„„„„„„„„");
  154.  
  155. j=strlen(n[0]);
  156. if (!j) gprint("„„„„„„„„„„„„„„„„„„„„"); else 
  157.    {for (k=0;k<((18-j)/2);k++) gprint("„");
  158.    gprint(" ");gprint(n[0]);gprint(" ");for (k=0;k<((18-j)/2);k++) gprint("„");}
  159.  
  160. for (i=0;i<l;i++){gotogxy(i,t+lx);gprint("");
  161. Wait();gotogxy(i,t+lx);gprint("_");
  162. }
  163. gotogxy(i-1,t+lx);gprint("…");
  164. i=lx;j=1;
  165.  
  166. }
  167.  
  168. void Title(){
  169. int i;
  170.  
  171. DISPLAY_ON;
  172. mode (M_TEXT_OUT);
  173. gotogxy(0,0);
  174. color(BLACK,WHITE,SOLID);
  175. gprint("„„       „„       „„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„    ");
  176. color(LTGREY,WHITE,SOLID);gprint("Mazezam");color(BLACK,WHITE,SOLID);
  177. gprint("     „„„„                „„„„");color(DKGREY,WHITE,SOLID);gprint("Original  ½ 2002");
  178. color(BLACK,WHITE,SOLID);gprint("„„„„                „„„„");color(DKGREY,WHITE,SOLID);gprint("Malcolm  Tyrrell");
  179. color(BLACK,WHITE,SOLID);gprint("„„„„                „„„„                „„„„");color(LTGREY,WHITE,SOLID);
  180. gprint(" Gameboy ½ 2004 ");
  181. color(BLACK,WHITE,SOLID);gprint("„„„„                „„„„");color(LTGREY,WHITE,SOLID);gprint("   by drHirudo  ");
  182. color(BLACK,WHITE,SOLID);gprint("„„„„                „„„„");
  183. gprint("„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„                    Press START to play");fadein();for (;;) { if (joypad() & J_START) break;
  184. i++;
  185. }
  186. initrand(i);
  187. }
  188.  
  189. char close=FALSE,TitleBool=FALSE;
  190.  
  191. void main() {
  192. int mazeno,ModeID,direction,count;
  193.  
  194. char Txt[20];
  195.  
  196. mazeno=1;lives=3;
  197.  
  198. _cpu=DMG_TYPE;
  199. BGP_REG = OBP0_REG = OBP1_REG = 0x00U;
  200. SHOW_BKG;
  201. HIDE_WIN;
  202. disable_interrupts();
  203. Title();Level(mazeno);
  204.  
  205. for(;;){
  206.  
  207. direction=joypad();
  208.  
  209. if (direction==J_SELECT) {lives--;if (lives>0){
  210.        color(BLACK,LTGREY,SOLID);gotogxy(l+j-3,t+i-1);gprint("ARGH!");delay(1500);
  211.           Level(mazeno);}
  212.  
  213. if (lives==0) {wait_vbl_done();gotogxy(5,8);color(DKGREY,LTGREY,SOLID);gprint("GAME OVER!");Delay(4200);reset();}
  214. }
  215.  
  216. if (direction == (J_START|J_SELECT|J_A)) {BGP_REG = 0x00U;reset();}
  217.  
  218. if (direction==J_RIGHT && (i==rx && j==w)) {
  219. gotogxy(l+j-1,t+i);gprint(" ");
  220. for (i=l+w;i<20;i++) {gotogxy(i,t+rx);gprint("");Wait();
  221. gotogxy(i,t+rx);gprint("_");}
  222. color(LTGREY,WHITE,SOLID);
  223. i=rand()%6;
  224. switch (i)
  225. {
  226. case 0: {gotogxy(12,t+rx);gprint("Hurray!A");break;}
  227.  
  228. case 1: {gotogxy(12,t+rx);gprint("Hurrah!A");break;}
  229.  
  230. case 2: {gotogxy(15,t+rx);gprint("Yes!A");break;}
  231.  
  232. case 3: {gotogxy(13,t+rx);gprint("Great!A");break;}
  233.  
  234. case 4: {gotogxy(11,t+rx);gprint("Yee-hah!A");break;}
  235.  
  236. default:{gotogxy(15,t+rx);gprint("Yay!A");}
  237.    }
  238. Delay(799);Level(++mazeno);
  239.  direction=0;}
  240. color (BLACK,WHITE,SOLID);
  241. if (direction==J_RIGHT && j<w) if (b[i][j]==' '){
  242. gotogxy(l+j-1,t+i);gprint(" ");j++;
  243. gotogxy(l+j-1,t+i);gprint("");} else
  244.  
  245. if (b[i][w-1]==' ') {j++;
  246. for (ModeID=w-1;ModeID>0;ModeID--) b[i][ModeID]=b[i][ModeID-1];
  247. b[i][0]=' ';b[i][w]=0;
  248. gotogxy(l,t+i); color ((i%2)+1,WHITE,SOLID);gprint(&b[i][0]);
  249. color (BLACK,WHITE,SOLID);
  250. gotogxy(l+j-1,t+i);gprint("");}
  251.  
  252. if (direction==J_LEFT && j>1) if (b[i][j-2]==' '){
  253. gotogxy(l+j-1,t+i);gprint(" ");j--;
  254. gotogxy(l+j-1,t+i);gprint("");} else
  255.  
  256. if (b[i][0]==' ') {j--;
  257. for (ModeID=1;ModeID<w;ModeID++) b[i][ModeID-1]=b[i][ModeID];
  258. b[i][w-1]=' ';
  259. for (count=0;count<w+1;count++) Txt[count]=b[i][count];
  260. gotogxy(l,t+i); color ((i%2)+1,WHITE,SOLID);gprint(&b[i][0]);
  261. color (BLACK,WHITE,SOLID);
  262. gotogxy(l+j-1,t+i);gprint("");}
  263.  
  264. if (direction==J_DOWN && i<h) if (b[i+1][j-1]==' '){
  265. gotogxy(l+j-1,t+i);gprint(" ");i++;
  266. gotogxy(l+j-1,t+i);gprint("");}
  267.  
  268. if (direction==J_UP && i>1) if (b[i-1][j-1]==' '){
  269. gotogxy(l+j-1,t+i);gprint(" ");i--;
  270. gotogxy(l+j-1,t+i);gprint("");}
  271.  
  272. direction=0;
  273.  
  274. Wait();
  275. }
  276.  
  277. }
  278.